<?php

/**
 * @package UC_PHPCodeModel
 * @author Uros Calakovic 
 */

/**
 * The CodeObject class is the base class for most code model objects.
 * 
 * @abstract 
 */

abstract class CodeObject 
{
    public function __construct()
    {
        $this->Comments = new CommentStatementCollection();
    }
    
    /**
     * __set() is used in CodeObject and inherited classes
     * to make private / protected variables accessible from outside the class.
     * 
     * __set() simply calls the appropriate field setter method.
     * It is still possible to call field setter methods directly.
     * 
     * @param string $name Name of the field to be accessed
     * @param mixed $value The value the field should be set to, usually a collection.
     */
    
    public function __set($name, $value)
    {
        if($name == 'Comments')
        {
            $this->set_Comments($value);
        }
    }
    
    /**
     * __get() is used in CodeObject and inherited classes
     * to make private / protected variables accessible from outside the class.
     * 
     * __get calls the appropriate field getter method.
     * It is still possible to call field getter method directly.
     * 
     * @param string $name Name of the field to be accessed
     * @return mixed The field that $name specified, usually a collection
     */
    
    public function __get($name)
    {
        if($name == 'Comments')
        {
            return $this->get_Comments();
        }
    }    
    
    /**
     * The $UserData getter method
     * 
     * @return mixed Returns any value stored in $UserData 
     */
    
    public function get_UserData()
    {
        return $this->UserData;
    }
    
    /**
     * The $UserData setter method
     * 
     * @param mixed $UserData An arbitrary value
     */
    
    public function set_UserData($UserData)
    {
        $this->UserData = $UserData;
    }

    /**
     * The $Comments getter method 
     * 
     * @return CommentStatementCollection 
     */
    
    public function get_Comments()
    {
        return $this->Comments;
    }
    
    /**
     * The $Comments setter method
     * 
     * @param CommentStatementCollection $Comments 
     */

    public function set_Comments(CommentStatementCollection $Comments)
    {
        $this->Comments = $Comments;
    }    
    
    /**
     * Stores the collection of comments for a code object.
     * 
     * @var CommentStatementCollection 
     */
    
    protected $Comments;    
    
    /**
     * Can contain arbitrary user-defined data related to a code object.
     * 
     * @var mixed
     */
    
    protected $UserData = null;
}

?>
